# ! /bin/bash

#关闭并退出数据库
#[[ "$1" = "open" ]] && {
#source ~/.bash_profile
#	mongo
#}

path="/Users/zhoumingle/Desktop/node_study/actual combat case2/student/model/connect.js"
node $path
if [ $? -eq 0 ]
then
	echo "mongodb running success..."
	exit 0
else 
	echo "mongodb failed!!"
	source ~/.bash_profile
	test $? -eq 0 && {
		mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork
		[[ "$?" = "0" ]] && {
			echo "mongodb start ok"
			mongo
			exit 0
		}
	}
	exit 1
fi	
